package com.cloudpolice.door.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.Date;

/**
 * @author ：梁昊，后端工程师：flyman5，前端工程师：孙耀
 * @create 2020-03-06 11:21
 * @function
 * @editLog
 */
public class FaceLogRecordMainModel {
    private String openAddress;
    private String openTypeName;

    /**
     * 开门方式（0:刷脸，1:RFID卡，2:二维码，3:远程开门）
     */
    @JsonIgnore
    private Integer openType;
    /**
     * 楼栋名
     */
    @JsonIgnore
    private String buildName;
    /**
     * 单元名
     */
    @JsonIgnore
    private String unitName;
    /**
     * 通道名
     */
    @JsonIgnore
    private String accessName;
    /**
     * 门禁机抓拍时间
     */
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date doorTime;

    public Integer getOpenType() {
        return openType;
    }

    public void setOpenType(Integer openType) {
        this.openType = openType;
    }

    public String getBuildName() {
        return buildName;
    }

    public void setBuildName(String buildName) {
        this.buildName = buildName;
    }

    public String getUnitName() {
        return unitName;
    }

    public void setUnitName(String unitName) {
        this.unitName = unitName;
    }

    public Date getDoorTime() {
        return doorTime;
    }

    public void setDoorTime(Date doorTime) {
        this.doorTime = doorTime;
    }

    public String getOpenAddress() {
        if (this.accessName == null)
            this.openAddress = String.format("%s-%s",buildName,this.unitName);
        else
            this.openAddress = accessName;
        return openAddress;
    }

    public String getOpenTypeName() {
//        0:刷脸，1:RFID卡，2:二维码，3:远程开门
        switch (openType) {
            case 0:
                openTypeName = "刷脸";
                break;
            case 1:
                openTypeName = "手环";
                break;
            case 2:
                openTypeName = "扫码";
                break;
            default:
                openTypeName = "远程";
                break;
        }
        return openTypeName + "开门";
    }

    public String getAccessName() {
        return accessName;
    }

    public void setAccessName(String accessName) {
        this.accessName = accessName;
    }
}
